package cn.yuanqiao.archive.appManager.domain;

import cn.yuanqiao.common.annotation.Excel;
import cn.yuanqiao.common.annotation.IdAnnotation;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.core.domain.BaseEntity;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.NotNull;

/**
 * trees对象 YQDA_TREES
 * 
 * @author 赵常飞
 * @date 2023-06-17
 */
public class YqdaTrees extends BaseEntity
{
    private final String BIGTABLENAME = "_TREES";

    public YqdaTrees() {
        String tenantCode = SecurityUtils.getLoginUser().getUser().getTenantCode();
        if(StringUtils.isEmpty(tenantCode)){
            throw new ServiceException("TenantCode is null");
        }else {
            this.tableName = tenantCode.toUpperCase()+BIGTABLENAME;
        }
    }
    private static final long serialVersionUID = 1L;
    private String tableName;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }
    /** 主键id */
    @IdAnnotation
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long id;

    /** 父节点 */
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long parentId;

    /** 名称 */
    @NotNull(message = "请填写名称")
    @Excel(name = "名称")
    private String name;

    /** 类型 */
    @Excel(name = "类型", readConverterExp = "t=树节点f=全宗节点a=门类节点c=分类节点n=空节点")
    private String type;

    /** 分类节点类型 */
    @Excel(name = "分类节点类型")
    private String propertyName;

    /** 分类节点值 */
    @Excel(name = "分类节点值")
    private String propertyValue;

    /** 门类节点门类id */
    @Excel(name = "门类节点门类id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long categoryId;

    /** 全宗节点全宗id */
    @Excel(name = "全宗节点全宗id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long fondsId;

    /** 分表名 */
    @Excel(name = "分表名")
    private String subTableName;

    /** 排序 */
    @Excel(name = "排序")
    private Integer orderNo;

    /** 创建人 */
    @Excel(name = "创建人")
    private String creator;

    /** 创建人id */
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long creatorId;

    /** 备注 */
    @Excel(name = "备注")
    private String remark;

    public void setId(Long Id) 
    {
        this.id = Id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setParentId(Long parentId) 
    {
        this.parentId = parentId;
    }

    public Long getParentId() 
    {
        return parentId;
    }
    public void setName(String name) 
    {
        this.name = name;
    }

    public String getName() 
    {
        return name;
    }
    public void setType(String type) 
    {
        this.type = type;
    }

    public String getType() 
    {
        return type;
    }
    public void setPropertyName(String propertyName) 
    {
        this.propertyName = propertyName;
    }

    public String getPropertyName() 
    {
        return propertyName;
    }
    public void setPropertyValue(String propertyValue) 
    {
        this.propertyValue = propertyValue;
    }

    public String getPropertyValue() 
    {
        return propertyValue;
    }
    public void setCategoryId(Long categoryId) 
    {
        this.categoryId = categoryId;
    }

    public Long getCategoryId() 
    {
        return categoryId;
    }
    public void setFondsId(Long fondsId) 
    {
        this.fondsId = fondsId;
    }

    public Long getFondsId() 
    {
        return fondsId;
    }
    public void setOrderNo(Integer orderNo) 
    {
        this.orderNo = orderNo;
    }

    public Integer getOrderNo() 
    {
        return orderNo;
    }
    public void setCreator(String creator) 
    {
        this.creator = creator;
    }

    public String getCreator() 
    {
        return creator;
    }
    public void setCreatorId(Long creatorId) 
    {
        this.creatorId = creatorId;
    }

    public Long getCreatorId() 
    {
        return creatorId;
    }
    @Override
    public void setRemark(String remark)
    {
        this.remark = remark;
    }
    @Override
    public String getRemark()
    {
        return remark;
    }

    public String getSubTableName() {
        return subTableName;
    }

    public void setSubTableName(String subTableName) {
        this.subTableName = subTableName;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("Id", getId())
            .append("parentId", getParentId())
            .append("name", getName())
            .append("type", getType())
            .append("propertyName", getPropertyName())
            .append("propertyValue", getPropertyValue())
            .append("categoryId", getCategoryId())
            .append("fondsId", getFondsId())
            .append("subTableName",getSubTableName())
            .append("orderNo", getOrderNo())
            .append("remark", getRemark())
            .append("creator", getCreator())
            .append("creatorId", getCreatorId())
            .append("createTime", getCreateTime())
            .toString();
    }
}
